package com.imti.mall.sale.controller;

import com.imti.mall.common.Api.CommonResult;
import com.imti.mall.model.sms.pojo.SmsFlashPromotion;
import com.imti.mall.model.sms.pojo.SmsFlashPromotionLog;
import com.imti.mall.sale.service.SmsFlashPromotionLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("")
@Api(tags = "限时购管理")
public class SmsFlashPromotionLogController {

    @Autowired
    SmsFlashPromotionLogService smsFlashPromotionLogService;


    @ApiOperation("添加限时购通知记录App")
    @PostMapping(value = "/addSmsFlashPromotionLog")
    public CommonResult addSmsFlashPromotionLog(@RequestBody SmsFlashPromotionLog smsFlashPromotionLog) {
        Integer req = smsFlashPromotionLogService.addSmsFlashPromotionLog(smsFlashPromotionLog);
        if(req>0){
            return CommonResult.success("添加成功");
        }else {
            return CommonResult.failed("添加失败");
        }

    }

    /**
     * 查询限时购通知记录表(可根据条件查询)
     * @param smsFlashPromotionLog
     * @return
     */
    @ApiOperation("询限时购通知记录表(可根据条件查询)")
    @PostMapping(value = "/findSmsFlashPromotionLog")
    public CommonResult findSmsFlashPromotionLog(@RequestBody SmsFlashPromotionLog smsFlashPromotionLog) {
        List<SmsFlashPromotionLog> smsFlashPromotionLogList = smsFlashPromotionLogService.findSmsFlashPromotionLog(smsFlashPromotionLog);
        if(smsFlashPromotionLogList!=null){
            return CommonResult.success(smsFlashPromotionLogList);
        }else {
            return CommonResult.failed("失败");
        }

    }


    /**
     * 根据id删除限时购通知记录表
     * @param smsFlashPromotionLog
     * @return
     */
    @ApiOperation("根据id删除限时购通知记录表")
    @PostMapping(value = "/delSmsFlashPromotionLog")
    public CommonResult delSmsFlashPromotionLog(@RequestBody SmsFlashPromotionLog smsFlashPromotionLog) {
        Integer integer = smsFlashPromotionLogService.delSmsFlashPromotionLog(smsFlashPromotionLog);
        if(integer>0){
            return CommonResult.success("删除成功");
        }else {
            return CommonResult.failed("删除失败");
        }

    }

}
